<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.io.PrintStream"%>
<%@page import="java.io.PrintWriter"%>
<%@page import="org.ribizli.basicgameserver.data.HibernateUtil"%>
<%@page import="org.hibernate.Session"%>
<%@page import="java.sql.Statement"%>
<%@page import="org.ribizli.basicgameserver.data.User"%>
<%@page import="org.hibernate.SessionFactory"%>
<%@page import="org.hibernate.cfg.AnnotationConfiguration"%>
<%@page import="org.hibernate.Hibernate"%><html>
<%!
static SessionFactory sessionFactory = null;
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test</title>
</head>
<body>
<%
  try {
    if (sessionFactory == null) {
	    sessionFactory = new AnnotationConfiguration()
	        .configure().buildSessionFactory();
    }
    response.getWriter().write("factory? " + sessionFactory);
    Session s = sessionFactory.openSession();
    response.getWriter().write("<br/>isConnected? " + s.isConnected());
    User u = (User) s.createQuery("from User as user where user.username = ?").setString(0, "ribizli").uniqueResult();
    Hibernate.initialize(u);
    s.close();
    response.getWriter().write(
        "<br/>User: " + u.getUsername());
  } catch (Exception e) {
    response.getWriter().write("<br/><pre>");
    e.printStackTrace(new PrintWriter(response.getWriter()));
    response.getWriter().write("</pre>");
  }
%>
</body>
</html>